//
//  M_PhotoMineDetailViewController.m
//  Model
//
//  Created by apple on 2018/7/12.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "M_PhotoMineDetailViewController.h"
#import "M_PhotoMineDetOneTableViewCell.h"
#import "M_PhotoMineDetTwoTableViewCell.h"
#import "M_PhotoMineDetOnePicTableViewCell.h"
#import "M_PhotoMineDetThreePicTableViewCell.h"
#import "M_PhotoMineDetSixPicTableViewCell.h"
#import "M_PhotoMineDetNineTableViewCell.h"
#import "UINavigationBar+Awesome.h"
/*图片放大*/
#import "YYPhotoBrowseView.h"

#import "MJRefresh.h"
#import "MJRefreshHeader.h"
#import "MJRefreshFooter.h"

#define NAVBAR_CHANGE_POINT 50
@interface M_PhotoMineDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *picArr;
@property (nonatomic, strong) NSMutableArray *nameArr;
@property (nonatomic, strong) NSMutableDictionary *nameDic;//上面数据
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) UIButton *guanZhuBtn;
@property (strong,nonatomic)NSMutableArray * imageViews;
@property (nonatomic, assign) NSInteger page2;

@end

@implementation M_PhotoMineDetailViewController
- (void)viewWillAppear:(BOOL)animated
{
//    [[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:255/255.0f green:255/255.0f blue:255/255.0f alpha:0.1]];
//    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255/255.0f green:255/255.0f blue:255/255.0f alpha:0.1]];
//    [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont systemFontOfSize:21], NSFontAttributeName, nil]];


    [super viewWillAppear:YES];
    self.tableView.delegate = self;
    [self scrollViewDidScroll:self.tableView];
    //设置导航栏透明
    [self.navigationController.navigationBar setTranslucent:true];
    //把背景设为空
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    //处理导航栏有条线的问题
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    

    [self.navigationController setNavigationBarHidden:NO animated:NO];
//    self.navigationController.navigationBar.alpha = 0;
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    [self creationData1];
    __weak typeof(self) weakself = self;
    [self creationData];
    
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        
        [weakself creationDataJZ];
    }];
    
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [weakself creationData];
        
        [self.tableView.mj_header beginRefreshing];
    }];
    
    
    
    
    
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.tableView.delegate = nil;
    [self.navigationController.navigationBar lt_reset];
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
//    if (KIsiPhoneX) {
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg_top"] forBarMetrics:UIBarMetricsDefault];
//    }else{
//        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg_3"] forBarMetrics:UIBarMetricsDefault];
//    }
    [self.navigationController.navigationBar setShadowImage:nil];
    self.navigationController.navigationBar.translucent = NO;

    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView2];
    [self regeditCell];

    _page2 = 1;

    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, screenScale(25), screenScale(25));
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"return"] forState:UIControlStateNormal];
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"return"] forState:UIControlStateSelected];
    [leftBtn addTarget:self action:@selector(leftNavItemClick) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *leftBarBtn=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem=leftBarBtn;
    
    [self.navigationController.navigationBar lt_setBackgroundColor:[UIColor clearColor]];
    // Do any additional setup after loading the view.
}
- (void)leftNavItemClick{
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    UIColor * color = getColor(@"ff40c6");
    CGFloat offsetY = scrollView.contentOffset.y;
    if (offsetY > NAVBAR_CHANGE_POINT) {
        CGFloat alpha = MIN(1, 1 - ((NAVBAR_CHANGE_POINT + (KIsiPhoneX?88:64) - offsetY) / (KIsiPhoneX?88:64)));
        [self.navigationController.navigationBar lt_setBackgroundColor:[color colorWithAlphaComponent:alpha]];
    } else {
        [self.navigationController.navigationBar lt_setBackgroundColor:[color colorWithAlphaComponent:0]];
    }
}

- (void)creationView2 {
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0,(KIsiPhoneX?-88:-64) , DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - (KIsiPhoneX?55:50)+(KIsiPhoneX?88:64));
    
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = getColor(@"f7f7f7");
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    [self.view addSubview:self.tableView];
    
    self.tableView.estimatedRowHeight = 400;
    
    self.tableView.separatorStyle = UITableViewCellAccessoryNone;
    
    UIView *footView = [[UIView alloc] init];
    [self.view addSubview:footView];
    footView.backgroundColor = [UIColor whiteColor];
    [footView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.bottom.equalTo(self.view);
        make.height.offset(50);
        
    }];
    self.guanZhuBtn = [[UIButton alloc] init];
    [footView addSubview:self.guanZhuBtn];
    [self.guanZhuBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.bottom.equalTo(self.view);
        make.top.equalTo(footView);
        
    }];
    

    
    
    [self.guanZhuBtn setTitleColor:getColor(@"ff40c6") forState:UIControlStateNormal];
    self.guanZhuBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    [self.guanZhuBtn addTarget:self action:@selector(guanZhuClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
}


- (void)regeditCell{
    
    
    
    [self.tableView registerNib:[UINib nibWithNibName:@"M_PhotoMineDetOneTableViewCell" bundle:nil] forCellReuseIdentifier:@"M_PhotoMineDetOneTableViewCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"M_PhotoMineDetTwoTableViewCell" bundle:nil] forCellReuseIdentifier:@"M_PhotoMineDetTwoTableViewCell"];
    
     [self.tableView registerNib:[UINib nibWithNibName:@"M_PhotoMineDetOnePicTableViewCell" bundle:nil] forCellReuseIdentifier:@"M_PhotoMineDetOnePicTableViewCell"];
    
    
    [self.tableView registerNib:[UINib nibWithNibName:@"M_PhotoMineDetThreePicTableViewCell" bundle:nil] forCellReuseIdentifier:@"M_PhotoMineDetThreePicTableViewCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"M_PhotoMineDetSixPicTableViewCell" bundle:nil] forCellReuseIdentifier:@"M_PhotoMineDetSixPicTableViewCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"M_PhotoMineDetNineTableViewCell" bundle:nil] forCellReuseIdentifier:@"M_PhotoMineDetNineTableViewCell"];
    
}

- (NSMutableArray *)dataArr{
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
    }
    return  _dataArr;
}
- (NSMutableArray *)picArr{
    if (!_picArr) {
        _picArr = [NSMutableArray array];
        
    }
    return _picArr;
    
}
- (NSMutableArray *)nameArr{
    if (!_nameArr) {
        _nameArr = [NSMutableArray array];
    }
    return _nameArr;
}
- (NSMutableDictionary *)nameDic{
    if (!_nameDic) {
        _nameDic = [NSMutableDictionary dictionary];
    }
    return _nameDic;
}
- (void)creationData1{
    
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *type = [NSString stringWithFormat:@"%ld", (long)self.modelId];
    [productParams setValue:type forKey:@"modelid"];
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    [productParams setValue:token forKey:@"token"];
    [[MNetworkHandler sharedInstance]conURL:modelinfo networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"Status"]intValue]==200) {
            
            self.nameDic = returnData[@"Data"];
      
            if ([[self.nameDic objectForKey:@"FollowState"] intValue] == 0) {
                [self.guanZhuBtn setTitle:@"未关注" forState:UIControlStateNormal];
            }else{
                [self.guanZhuBtn setTitle:@"已关注" forState:UIControlStateNormal];
            }
            [self.tableView reloadData];
   
        }
        
        else {
            
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"Msg"] duration:5.0f];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        //        [hud removeFromSuperview];
    }];
    
    
}
- (void)creationData{
//    _dataArr = [NSMutableArray array];
    [self.tableView.mj_header endRefreshing];
    
    
    _page2 = 1;
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page2];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    [productParams setValue:strPage forKey:@"page"];
    
    //    [productParams setValue:@"10" forKey:@"pagesize"];
    NSString *type = [NSString stringWithFormat:@"%ld", (long)self.modelId];
    [productParams setValue:type forKey:@"modelid"];

    [[MNetworkHandler sharedInstance]conURL:modelspace networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"Status"]intValue]==200) {
            
            self.dataArr = [returnData objectForKey:@"Data"];
            
//            for (int i = 0; i< self.dataArr.count; i++) {
//                [self.picArr addObject:[self.dataArr[i]objectForKey:@"imgs"]];
//                [self.nameArr addObject:[self.dataArr[i] objectForKey:@"album"]];
//
//            }
//
            NSLog(@"DDDDDDDDDDDD%@", self.dataArr);
            NSLog(@"PPPPPPPPPPPPPPPPPPPPP%@", self.picArr);
            NSLog(@"NNNNNNNNNNNNNNNNNNNN%@", self.nameArr);
            [self.tableView reloadData];
            //
            //
            //            [hud removeFromSuperview];
        }
        
        else {
            
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"Msg"] duration:5.0f];
            //            [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        //        [hud removeFromSuperview];
    }];
    
    
    //    }
    
    
    
}
- (void)creationDataJZ{
    
    _page2++;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page2];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    [productParams setValue:strPage forKey:@"page"];

    //    [productParams setValue:@"10" forKey:@"pagesize"];
    NSString *type = [NSString stringWithFormat:@"%ld", (long)self.modelId];
    [productParams setValue:type forKey:@"modelid"];
    
    [[MNetworkHandler sharedInstance]conURL:modelspace networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"Status"]intValue]==200) {
            
            NSMutableArray *arr =[returnData objectForKey:@"Data"];
            
            if (arr.count == 0) {
                
                [self.tableView.mj_footer endRefreshing];
                
            }else {
                
                [self.dataArr addObjectsFromArray:arr];
                
                NSLog(@"JZJZJZJZJZJJZJZJZJZJZJJZJZ%@", self.dataArr);
                
                
            }
            //
            //
            [self.tableView reloadData];
            [self.tableView.mj_footer endRefreshing];
            //
        }
        //
        else {
            //
            //            [PublicFunction showAlert:nil message:@"没有更多照片" duration:5.0f];
            [self.tableView.mj_footer endRefreshing];
            //
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        
    }];
    //    }
    
    
}
#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }else{
        
        return self.dataArr.count;
    }
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 300;
    }else{
        return UITableViewAutomaticDimension;
    }
   
    
    
    
    
}

#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        M_PhotoMineDetOneTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetOneTableViewCell" forIndexPath:indexPath];
        
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        
        //        [cell.backButton addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
        cell.backButton.hidden = YES;
        cell.name.text = [self.nameDic objectForKey:@"name"];
        [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
        cell.imgView.contentMode = UIViewContentModeScaleAspectFill;
        cell.imgView.clipsToBounds = YES;
        cell.imgView.userInteractionEnabled = YES;
        cell.height.text = [NSString stringWithFormat:@"%ldCM",[[self.nameDic  objectForKey:@"height"]integerValue]];
        cell.hot.text = [NSString stringWithFormat:@"已有%ld人关注",[[self.nameDic  objectForKey:@"hot"]integerValue]];
        cell.weight.text = [NSString stringWithFormat:@"%ldKG",[[self.nameDic  objectForKey:@"weight"]integerValue]];
        [cell.imgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"BackImg"]] placeholderImage:[UIImage imageNamed:@""]];
        NSString *strUrl = [[self.nameDic objectForKey:@"bwh"] stringByReplacingOccurrencesOfString:@"," withString:@"/"];

        cell.bwh.text = strUrl;
        
        return cell;
    }else{
        
        self.picArr = [self.dataArr[indexPath.row] objectForKey:@"imgs"];
        NSMutableDictionary *nameDic = [self.dataArr[indexPath.row] objectForKey:@"album"];

        if (self.picArr.count == 0) {

            M_PhotoMineDetTwoTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetTwoTableViewCell" forIndexPath:indexPath];
            
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            return cell;
            
        }else if (self.picArr.count == 1){
            M_PhotoMineDetOnePicTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetOnePicTableViewCell" forIndexPath:indexPath];
            
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgVeiw sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            __weak typeof(self) weakself = self;
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;

        }else if (self.picArr.count == 2){
            M_PhotoMineDetThreePicTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetThreePicTableViewCell" forIndexPath:indexPath];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview2 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[1]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.imgview3.hidden = YES;
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            cell.imgview2.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview2.clipsToBounds = YES;
            cell.imgview2.userInteractionEnabled = YES;
            __weak typeof(self) weakself = self;
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;
            
        }else if (self.picArr.count == 3){
            M_PhotoMineDetThreePicTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetThreePicTableViewCell" forIndexPath:indexPath];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview2 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[1]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview3 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[2]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            cell.imgview2.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview2.clipsToBounds = YES;
            cell.imgview2.userInteractionEnabled = YES;
            cell.imgview3.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview3.clipsToBounds = YES;
            cell.imgview3.userInteractionEnabled = YES;
            
            __weak typeof(self) weakself = self;
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;
            
        }else if (self.picArr.count == 4){
            M_PhotoMineDetSixPicTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetSixPicTableViewCell" forIndexPath:indexPath];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview2 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[1]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview3 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[2]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            [cell.imgview4 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[3]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            cell.imgview2.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview2.clipsToBounds = YES;
            cell.imgview2.userInteractionEnabled = YES;
            cell.imgview3.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview3.clipsToBounds = YES;
            cell.imgview3.userInteractionEnabled = YES;
            cell.imgview4.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview4.clipsToBounds = YES;
            cell.imgview4.userInteractionEnabled = YES;
            
            cell.imgview5.hidden = YES;
            cell.imgview6.hidden = YES;
            
            __weak typeof(self) weakself = self;
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;
            
        }else if (self.picArr.count == 5){
            M_PhotoMineDetSixPicTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetSixPicTableViewCell" forIndexPath:indexPath];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview2 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[1]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview3 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[2]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            [cell.imgview4 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[3]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview5 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[4]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            cell.imgview2.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview2.clipsToBounds = YES;
            cell.imgview2.userInteractionEnabled = YES;
            cell.imgview3.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview3.clipsToBounds = YES;
            cell.imgview3.userInteractionEnabled = YES;
            cell.imgview4.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview4.clipsToBounds = YES;
            cell.imgview4.userInteractionEnabled = YES;
            cell.imgview5.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview5.clipsToBounds = YES;
            cell.imgview5.userInteractionEnabled = YES;
            
            cell.imgview6.hidden = YES;
            
            __weak typeof(self) weakself = self;
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;
            
        }else if (self.picArr.count == 6){
            M_PhotoMineDetSixPicTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetSixPicTableViewCell" forIndexPath:indexPath];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview2 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[1]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview3 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[2]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            [cell.imgview4 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[3]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview5 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[4]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview6 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[5]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            cell.imgview2.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview2.clipsToBounds = YES;
            cell.imgview2.userInteractionEnabled = YES;
            cell.imgview3.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview3.clipsToBounds = YES;
            cell.imgview3.userInteractionEnabled = YES;
            cell.imgview4.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview4.clipsToBounds = YES;
            cell.imgview4.userInteractionEnabled = YES;
            cell.imgview5.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview5.clipsToBounds = YES;
            cell.imgview5.userInteractionEnabled = YES;
            cell.imgview6.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview6.clipsToBounds = YES;
            cell.imgview6.userInteractionEnabled = YES;
            
            __weak typeof(self) weakself = self;
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;
            
        }else if (self.picArr.count == 7){
            M_PhotoMineDetNineTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetNineTableViewCell" forIndexPath:indexPath];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview2 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[1]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview3 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[2]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            [cell.imgview4 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[3]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview5 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[4]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview6 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[5]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview7 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[6]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            cell.imgview2.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview2.clipsToBounds = YES;
            cell.imgview2.userInteractionEnabled = YES;
            cell.imgview3.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview3.clipsToBounds = YES;
            cell.imgview3.userInteractionEnabled = YES;
            cell.imgview4.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview4.clipsToBounds = YES;
            cell.imgview4.userInteractionEnabled = YES;
            cell.imgview5.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview5.clipsToBounds = YES;
            cell.imgview5.userInteractionEnabled = YES;
            cell.imgview6.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview6.clipsToBounds = YES;
            cell.imgview6.userInteractionEnabled = YES;
            cell.imgview7.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview7.clipsToBounds = YES;
            cell.imgview7.userInteractionEnabled = YES;
            
            cell.imgview8.hidden = YES;
            cell.imgview9.hidden = YES;
            __weak typeof(self) weakself = self;
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;
            
        }else if (self.picArr.count == 8){
            M_PhotoMineDetNineTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetNineTableViewCell" forIndexPath:indexPath];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview2 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[1]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview3 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[2]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            [cell.imgview4 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[3]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview5 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[4]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview6 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[5]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview7 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[6]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview8 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[7]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            cell.imgview2.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview2.clipsToBounds = YES;
            cell.imgview2.userInteractionEnabled = YES;
            cell.imgview3.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview3.clipsToBounds = YES;
            cell.imgview3.userInteractionEnabled = YES;
            cell.imgview4.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview4.clipsToBounds = YES;
            cell.imgview4.userInteractionEnabled = YES;
            cell.imgview5.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview5.clipsToBounds = YES;
            cell.imgview5.userInteractionEnabled = YES;
            cell.imgview6.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview6.clipsToBounds = YES;
            cell.imgview6.userInteractionEnabled = YES;
            cell.imgview7.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview7.clipsToBounds = YES;
            cell.imgview7.userInteractionEnabled = YES;
            cell.imgview8.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview8.clipsToBounds = YES;
            cell.imgview8.userInteractionEnabled = YES;
            cell.imgview9.hidden = YES;
            __weak typeof(self) weakself = self;
            
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;
            
        } else{
            M_PhotoMineDetNineTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_PhotoMineDetNineTableViewCell" forIndexPath:indexPath];
            cell.name.text = [self.nameDic objectForKey:@"name"];
            [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:[self.nameDic objectForKey:@"head"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = self.picArr;
            cell.describe.text = [nameDic objectForKey:@"describe"];
            cell.describetime.text = [nameDic objectForKey:@"describetime"];
            [cell.imgview1 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[0]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview2 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[1]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview3 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[2]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            
            [cell.imgview4 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[3]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview5 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[4]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview6 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[5]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview7 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[6]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview8 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[7]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            [cell.imgview9 sd_setImageWithURL:[NSURL URLWithString:[arrOfPic[8]objectForKey:@"albumimage"]] placeholderImage:[UIImage imageNamed:@""]];
            cell.imgview1.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview1.clipsToBounds = YES;
            cell.imgview1.userInteractionEnabled = YES;
            cell.imgview2.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview2.clipsToBounds = YES;
            cell.imgview2.userInteractionEnabled = YES;
            cell.imgview3.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview3.clipsToBounds = YES;
            cell.imgview3.userInteractionEnabled = YES;
            cell.imgview4.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview4.clipsToBounds = YES;
            cell.imgview4.userInteractionEnabled = YES;
            cell.imgview5.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview5.clipsToBounds = YES;
            cell.imgview5.userInteractionEnabled = YES;
            cell.imgview6.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview6.clipsToBounds = YES;
            cell.imgview6.userInteractionEnabled = YES;
            cell.imgview7.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview7.clipsToBounds = YES;
            cell.imgview7.userInteractionEnabled = YES;
            cell.imgview8.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview8.clipsToBounds = YES;
            cell.imgview8.userInteractionEnabled = YES;
            cell.imgview9.contentMode = UIViewContentModeScaleAspectFill;
            cell.imgview9.clipsToBounds = YES;
            cell.imgview9.userInteractionEnabled = YES;
            __weak typeof(self) weakself = self;
            [cell callBackOfPicBlock:^{
                
                
                [weakself editWorkExperienceWithModel:arrOfPic andNum:cell.num];
                
                
            }];
            
            return cell;
            
        }
    }
        

    
}
#pragma mark - ---------- 每个Cell的点击事件 ----------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    //    if (indexPath.row == 0) {
    //
    //    }else{
    //
    //        TL_GongYiFPZXViewController *vc = [[TL_GongYiFPZXViewController alloc] init];
    //        [self presentViewController:vc animated:YES completion:^{
    //            NSLog(@"present成功，从ViewController切换到FirstViewController");//此方法调用了会执行这行代码
    //        }];
    //
    //
    //    }
    
    
    
}
//图片点击放大
- (void)editWorkExperienceWithModel:(NSMutableArray *)arr andNum:(NSInteger )num{
    
    
    _imageViews = [NSMutableArray array];
    
    
    //   self.tabBarController.tabBar.hidden = YES;
    NSMutableArray *items = [NSMutableArray array];
    NSMutableArray *myarr=[[NSMutableArray alloc]init];
    
    UIView *fromView = nil;
    
    for (NSInteger i = 0; i < arr.count; i++) {
        
        YYPhotoGroupItem *item = [YYPhotoGroupItem new];
        NSString *str=[arr[i] objectForKey:@"albumimage"];
        
//        NSString *urlN=manage(AP_HOST, str);
        
        NSURL *url = [NSURL URLWithString:str];
        
        [myarr addObject:str];
        
        UIImageView *imageview=[[UIImageView alloc] init];
        
        [imageview sd_setImageWithURL:[NSURL URLWithString:myarr[i]] placeholderImage:[UIImage imageNamed:@""]];
        
        [self.imageViews addObject:imageview];
        
        item.thumbView = self.imageViews[i];
        
        
        item.largeImageURL = url;
        [items addObject:item];
        if (i == num-1) {
            fromView = self.imageViews[i];
        }
    }
    
    //YYPhotoBrowseView
    
    YYPhotoBrowseView *groupView = [[YYPhotoBrowseView alloc]initWithGroupItems:items];
    
    
    
    [groupView presentFromImageView:fromView toContainer:self.tabBarController.view animated:NO completion:nil];
    
    
    
}
#pragma mark -------------- 关注
- (void)guanZhuClick:(UIButton *)sender{
    sender.selected =!sender.selected;
//    sender.selected =!sender.selected;
//    if ([self.guanZhuBtn.titleLabel.text isEqualToString:@"未关注"]) {
//        NSLog(@"1");
//        [self.guanZhuBtn setTitle:@"已关注" forState:UIControlStateNormal];
//    }else{
//        NSLog(@"2");
//        [self.guanZhuBtn setTitle:@"未关注" forState:UIControlStateNormal];
//
//    }
    
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *type = [NSString stringWithFormat:@"%ld", (long)self.modelId];
    [productParams setValue:type forKey:@"modelId"];
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    [productParams setValue:token forKey:@"token"];
    [[MNetworkHandler sharedInstance]conURL:follow networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"Status"]intValue]==200) {
     
            [self creationData1];
            
        }
        
        else {
            

            [PublicFunction showAlert:nil message:[returnData objectForKey:@"Msg"] duration:5.0f];
            //            [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        //        [hud removeFromSuperview];
    }];
    
    
    
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
